import type { RootState } from '@/store';
import type { SettingState } from './state'
import type { Store as VuexStore, Module, CommitOptions, DispatchOptions } from "vuex";

import { state } from './state'
import { mutations, type Mutations } from './mutations'
import { actions, type Actions } from './actions'

export type { SettingState }

export type SettingStore<S = SettingState> = Omit<VuexStore<S>, 'getters' | 'dispatch' | 'commit'>
  & {
    commit<K extends keyof Mutations, P extends Parameters<Mutations[K]>[1]> (
      kye: K,
      payload: P,
      options?: CommitOptions
    ): ReturnType<Mutations[K]>
  }
  & {
    dispatch<K extends keyof Actions> (
      key: K,
      payload: Parameters<Actions[K]>[1],
      options: DispatchOptions
    ): ReturnType<Actions[K]>
  }

export const store: Module<SettingState, RootState> = {
  state,
  mutations,
  actions
}
